
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>经济管理学院</title>
<link rel="stylesheet" href='css/style.css' type="text/css">

</head>
<script type='text/javascript' src='js/prototype.js'></script>
<script type='text/javascript' src='js/sha1.js'></script>
<script type='text/javascript' src='js/public.js'></script>
<script type="text/javascript">
function showuserkey(){
	var params = "user_keyName=userName&user_keyName=privilegeToCreateLecture";
	new Ajax.Request("json/showUser_key", {
		method : "post",
		parameters : params,
		onComplete : function(request) {
			var res = request.responseText.evalJSON();
		
			if(res["result"]["userName"]==null||res["result"]["privilegeToCreateLecture"]=="0")
				window.location.href="login.html";
			document.getElementById("username").innerHTML = "欢迎 "
				+ res["result"]["userName"];
		},
		asynchronous : true
	});
	online();
	iteratorLectures();
}


function viewLecturesOutline(productId) {
	
	var params = "lectureId=" + productId;
	new Ajax.Request(
			"json/viewLecturesOutline",
			{
				method : "post",
				parameters : params,
				onComplete : function(request) {
					var res = request.responseText.evalJSON();
					
					
					if (res["result"]["flag"] == "true") {
						var grade=" ";
						if(res["result"]["userEnterYear1"]!==null)
						 grade += res["result"]["userEnterYear1"]+" ";
						if(res["result"]["userEnterYear2"]!==null)
							 grade += res["result"]["userEnterYear2"]+" ";
						if(res["result"]["userEnterYear3"]!==null)
							 grade += res["result"]["userEnterYear3"]+" ";
						if(res["result"]["userEnterYear4"]!==null)
							 grade += res["result"]["userEnterYear4"]+" ";
						var start= compareTime(res["result"]["startTime"]);
						var stop=compareTime(res["result"]["stopTime"]);
						var shake=res["result"]["shake"];
					     var status="";
						if(start=="大于"){
							status+="未到报名时间"+res["result"]["startTime"];
							var nohtml="<li>"+res["result"]["lecName"]+"</li>";
							
							$("no").innerHTML += nohtml;
								
						}
						if(start=="小于"&stop=="大于"){
						   status+="正在报名中 截止时间"+res["result"]["stopTime"];
						   var onhtml="<li>"+res["result"]["lecName"] +"</li>";
						   $("on").innerHTML +=onhtml;}
					
						if(stop=="小于"&shake=="0"){
							var shakehtml="<li>"+res["result"]["lecName"] +"</li>";
							$("wait").innerHTML +=shakehtml;
							status+="报名已经截止,等待摇号";
						}
						if(stop=="小于"&shake=="1"){
							status+="报名已经截止,已经完成摇号";
						}
						var tmp = "<ul style='width:100%;border-bottom:1px  #999 dotted;'><li style='margin-left:20px; margin-top:20px;'><a href='OperateLeacture.html?lectureId="+res["result"]["lectureId"]+"'>主题："
						+strShorten(res["result"]["lecName"],40)
						+" </a></li><li style='margin-left:20px;'>主讲人："+res["result"]["lecSpeaker"]
						+"</li><li style='margin-left:20px;'>举办时间："+res["result"]["lecTime"]
						+"</li><li style='margin-left:20px;'>举办地点："+res["result"]["lecPlace"]
						+"</li><li style='margin-left:20px;''>参与年级："+grade
						+"</li><li style='margin-left:20px;''>备注："+ strShorten(res["result"]["lecNote"],40)
						+ "</li><li style='margin-left:20px;'>状态："+status+"</li></ul>";
						$("iteratorProductsTarget").innerHTML += tmp;
						document.getElementById("username").innerHTML = "欢迎 "
							+ res["result"]["uname"];
					}
				},
				asynchronous : false
			});
}
function iteratorLectures() {

	var request = {
		QueryString : function(val) {
			var uri = window.location.search;
			var re = new RegExp("" + val + "=([^&?]*)", "ig");
			return ((uri.match(re)) ? (uri.match(re)[0]
					.substr(val.length + 1)) : null);
		}
	};
	var max = request.QueryString("max");
	var first = request.QueryString("first");
	if (max == null || first == null) {
		max = 3;
		first = 0;
	}
	var curpage=request.QueryString("curpage");
	if(curpage==null)
		curpage=1;
	

	var params = "max=" + max + "&first=" + first;
	new Ajax.Request(
			"json/iteratorLectures",
			{
				method : "post",
				parameters : params,
				onComplete : function(request) {
					var res = request.responseText.evalJSON();
					if (res["result"]["flag"] == "true") {
						for (var i = 0; res["result"]["LectureId" + i] != null; i++) {
							viewLecturesOutline(res["result"]["LectureId"
									+ i]);
						}

						var amount = res["result"]["amountOfLectures"];
						var CountPage = parseInt(amount / max);
						if (amount % max > 0)
							CountPage++;
						var nextpage=parseInt(curpage)+1;
						var prepage=parseInt(curpage) - 1;
						var last=(CountPage-1)*max;
						document.getElementById("amountOfLectures").innerHTML = "共"
								+ amount + "条记录";
						document.getElementById("CountPage").innerHTML = "分"
							+ CountPage + "页";
						document.getElementById("curpage").innerHTML = "当前第"
							+ curpage + "页";
						document.getElementById("firstPage").innerHTML = "<a href='TeacherIndex.html?max="
								+ max + "&first=" + 0 + "&curpage=" + 1 + "' >第一页</a>";
						document.getElementById("lastPage").innerHTML = "<a href='TeacherIndex.html?max="
								+ max
								+ "&first="
								+ last
								+ "&curpage=" + CountPage + "' >尾页</a>";

						var next = parseInt(first) + parseInt(max) >= parseInt(amount) ? parseInt(amount) - parseInt(max)
								: parseInt(first) + parseInt(max);
						var previous = parseInt(first) - parseInt(max) <= 0 ? 0 : parseInt(first) - parseInt(max);
						if(prepage>0)
						document.getElementById("previous").innerHTML = "<a href='TeacherIndex.html?max="
								+ max + "&first=" + previous + "&curpage=" + prepage + "' >上一页</a>&nbsp";
								if(nextpage<=CountPage)
						document.getElementById("next").innerHTML = "<a href='TeacherIndex.html?max="
								+ max + "&first=" + next + "&curpage=" + nextpage + "' >下一页</a>&nbsp";

					

						
					}
				},
				asynchronous : false
			});
	
}

</script>
<body onload="showuserkey()">
	<div id="header">

			<div id="nav">
				<ul style="	float: left;padding: 0 20px;text-align: center;line-height: 50px;">
					<li style="float: left; font-size: 28px">经管院学术讲坛事务系统</li>
				</ul>
                   <ul class="horizon">
			
			<li class="login">
				<ul class="vertical">
			<li class="userInfo" id="username">&nbsp;你好</li>
			<li class="userInfo2">
					<ul class="horizon">
					
					<li><a href="adminUser.html" target="_blank" style=" text-decoration: none;">用户信息管理</a><br/><a onclick="outline()" style=" text-decoration: none;" href="#" >注销</a></li>
				</ul>
			</li>
		</ul>
	</li>
			
		</ul>
			</div>
		
			
		
	
	</div>
	<div id="main" >
        <div style=" width:21%; height:660px; border-right: 3px #660033 solid;  float:left; background-color:rgb(242, 247, 252);">
            <div style="width:100%; margin-top:50px;">
            <p style="margin-left:15px; font-size: 18px">工作简述</p><br>
                 <ul style="margin-left:20px;" id="no">未开始报名的讲座：
                 </ul>
                 <ul style="margin-left:20px; margin-top:20px" id="on">正在报名的讲座:
                 </ul>
                 <ul style="margin-left:20px; margin-top:20px" id="wait">等待摇号的讲座:
                 </ul>
                 <ul style="margin-left:20px; margin-top:20px"></ul><br>
               <p style="margin-left:15px; font-size: 18px"><a href="UserInfo.html" style="text-decoration: none;" target="_blank">信息统计</p></a> 
                 
                 
           </div></div>
		<div style="width:78%;font-size: 22px; float:right">
        <div style="margin-top:50px; margin-left:50px;height:560px">
		   <table width="800" border="0" style="font-size:14px;border:2px solid #999;">
  <tr>
    <td  style="border-bottom:1px #999 dotted;">	<li id="firstPage" style="float:left; width:50px;margin-left:100px;"></li>
					<li id="previous" style="float:left; width:50px"></li>
					
				
					
					<li id="next" style="float:left; width:50px; "></li>
					<li id="lastPage" style="float:left; width:50px"></li>
					<li id="amountOfLectures" style="float:left; width:80px"></li>
					<li id="CountPage" style="float:left; width:50px"></li>
					<li id="curpage" style="float:left; width:80px"></li>
					<li style="float: left; margin-left: 50px;"><a href="addLecture.html" style="text-decoration: none;">发布新的讲座</a></li>
					</td>
  </tr>
  <tr>
    <td style="font-size:16px;"><div id="iteratorProductsTarget">
				
				</div>
				
				</td>
  </tr>
</table>


        </div>
                <div style="font-size:14px; margin-left:100px;">
           	<span id="online">当前在线人数:</span>
    	    <span style="margin-left:150px">Copyright &copy; 2013  经济管理学院 北京市海淀区清华东路35号 邮编：100083</span>
        </div>
		</div>

	</div>

</body>
</html>
